package com.project.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.CarBean;
import com.project.mapper.ICarMapper;
import com.project.service.ICarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class CarServiceImpl implements ICarService {
    @Autowired
    private ICarMapper mapper;

    @Override
    public PageInfo<CarBean> findByItem(int pageNO, Integer startPrice, Integer endPrice, String color) {
        PageHelper.startPage(pageNO,PAGESIZE);
        PageInfo<CarBean> info = PageInfo.of(mapper.findByItem(startPrice,endPrice,color));

        return info;
    }

    @Override
    public void add(CarBean car) {
        mapper.add(car);
    }

    @Override
    public void del(int id) {
        mapper.del(id);
    }

    @Override
    public void update(int id, int price) {
        mapper.update(id,price);
    }

    @Override
    public CarBean findById(int id) {
        return mapper.findById(id);
    }
}
